package com.medical.medical.controller.gyncontroller;

import com.medical.medical.entity.Role;
import com.medical.medical.mapper.RoleMapper;
import com.medical.medical.service.RoleService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * @authorDesc 你相信光吗？
 * @author GUOYN
 * @date 2022-09-15 15:49:47
 * @version 1.0.0
 * @description 角色请求层
 */
@Slf4j
@Controller
public class GYNRoleController {
    @Resource
    private RoleService roleService;
    /**
      * @description 获得角色信息
      * @author GUOYN
      * @date 2022-09-15 15:53:13  * @param model
      * @return {@link String}
      */
    @RequestMapping("rolelist")
    public String getRoleList(Model model){
        List<Role> roleList = roleService.getRoleList();
        if (roleList!=null&&roleList.isEmpty()){
            model.addAttribute("roleFlag",1);
            model.addAttribute("result","未查询到角色信息！请退出重进！");
        }else {
            model.addAttribute("roleList",roleList);
        }
        return "/admin/rolelist";
    }
}
